/**
 * Created by WT-SUN on 2017/5/10.
 */
$(function () {
    $('#userTb').datagrid({
        rownumbers: true,//显示行号
        striped: true,
        fit: true,
        singleSelect: true,
        sortOrder: true,
        fitColumns: true,
        pagination: true,
        url: ROOT_PATH + '/train/record/UserTable.shtml',
        queryParams: {
            sort: 'addTime',
            order: 'desc',
            recordId:$.getQueryParam('id')
        },
        columns: [[
            {
                field: 'id', title: 'id', hidden:true,width: 20
            },
            {field: 'userId', title: 'userId', hidden:true,width: 100},
            {field: 'realName', title: '姓名', width: 100},
            {
                field: 'CompanyName',
                title: '所属部门',
                width: 100,
                formatter: function (value, row, index) {
                    var name = '';
                    if (row.userDepartmentList && row.userDepartmentList.length > 0) {
                        for (var index in row.userDepartmentList) {
                            if (row.userDepartmentList[index].deptName != null) {
                                name += ',' + row.userDepartmentList[index].deptName;
                            }
                        }
                        return name.substring(1);
                    } else {
                        return '';
                    }
                }
            },
            {field: 'code', title: '编号', width: 100},
            {field: 'isQualified', title: '是否合格', width: 100,
                formatter: function (value, row, index){
                    return row.isQualified=='1'?'是':(row.isQualified=='0'?'否':'');
                }},
            {field: 'score', title: '成绩', width: 100}
        ]]
    });
});